package br.com.officium.sessionbean;

import br.com.officium.entidade.cadastro.Recurso;
import br.com.officium.interceptor.SecurityCreateUpdateInterceptor;
import java.util.Calendar;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.interceptor.Interceptors;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Ivo
 */
@Stateless
@LocalBean
public class RecursoBsn extends AbstractSessionBean<Recurso> {

    @PersistenceContext
    private EntityManager em;

    public RecursoBsn() {
        super(Recurso.class);
    }

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    @Override
    @Interceptors({SecurityCreateUpdateInterceptor.class})
    public void create(Recurso entity) {
        entity.setDataCadastro(Calendar.getInstance().getTime());
        super.create(entity);
    }

    @Override
    @Interceptors({SecurityCreateUpdateInterceptor.class})
    public void edit(Recurso entity) {
        entity.setDataAtualizacao(Calendar.getInstance().getTime());
        super.edit(entity);
    }

}
